home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
Forwhile.pxl
< prev
next >
Wrap
Text File
|
2000-12-23
|
4KB
|
193 lines
Initialize:
WinGetActive(Win$)
UseCoordinates(PIXEL)
UseBackGround(TRANSPARENT,192,192,192)
DrawBackGround
WaitInput(100) {let NT and 95 catch up}
InfoMenu(REMOVE)
SetMenu()
WinLocate(Win$,250,10,620,240,Res)
Title$ = "For and While Loops"
WinTitle(Win$, Title$)
{WinShow(Title$,NOTOPMOST,Res)}
DirGet(SourceDir$)
SetMenu("E&xit!",Leave,
ENDPOPUP,
"&FOR Loops",IGNORE,
"&Programmed FOR",ProgramFor,
"&Structured FOR",ConstructFor,
ENDPOPUP,
"&WHILE Loops",IGNORE,
"&Programmed WHILE",ProgramWhile,
"&Structured WHILE",ConstructWhile,
ENDPOPUP,
"For-&If-While",ForIfWhile,
ENDPOPUP,
"&Help",IGNORE,
"&Concept",Concept,
"&View Source",ViewSource,
"&About",About,
ENDPOPUP)
Wait_for_Input:
WaitInput()
Leave:
End
Concept:
MessageBox(OK,1,INFORMATION,
"This sample program demonstrates the two
available methods of programming FOR and
WHILE loops, using firstly:
Labels and 'Goto' statements;
and secondly:
Structured FOR and WHILE
Keywords.
Look in the sources to see the differences.",
"Structured Program controls",Res)
Goto Wait_for_Input
ViewSource:
PXLFile$ = SourceDir$ + "\forwhile.pxl"
CmdLine$ = "NotePad " + PXLFile$
Run(CmdLine$)
Goto Wait_for_Input
About:
AboutUser("Structured Program Loops with PiXCL 4.2",
"FOR - NEXT and WHILE - ENDWHILE structures in PiXCL",
"Sample PiXCL 4.2 program showing variety of built in icons drawn in the client area, depending on the loop parameters")
Goto Wait_for_Input
ProgramFor:
Count = 0
DrawBackGround
For_Loop:
DrawIcon( 1,1,0,0,ICON01)
DrawIcon(41,1,0,0,ICON02)
DrawIcon(81,1,0,0,ICON03)
Count++
Break
If Count <= 200 Then Goto For_Loop
DrawText(10,50,"Programmed For Loop complete")
Goto Wait_for_Input
ConstructFor:
DrawBackGround
For Count = 0 To 10 By 2
DrawIcon( 1,1,0,0,ICON01)
For InnerCount = 0 To 6 By 2
If InnerCount = 6 Then DebugMsgBox("Inner For Loop")
Next
DrawIcon(41,1,0,0,ICON02)
If Count > 40 Then DrawIcon( 1,1,64,64,ICON11) Break
DrawIcon(81,1,0,0,ICON03)
Next
DrawNumber(150,20,Count)
DrawText(10,80,"Structured For Loop complete.")
Goto Wait_for_Input
ProgramWhile:
Count = 0
DrawBackGround
While_Loop:
If Count > 100 Then Goto While_End
DrawIcon( 1,1,0,0,ICON04)
DrawIcon(41,1,0,0,ICON05)
DrawIcon(81,1,0,0,ICON06)
Count++
Goto While_Loop
While_End:
DrawText(10,50,"Programmed While Loop complete.")
Goto Wait_for_Input
ConstructWhile:
Count = 0
DrawBackGround
While Count <= 5
DrawIcon( 1,1,0,0,ICON04)
DrawIcon(41,1,0,0,ICON05)
DrawIcon(81,1,0,0,ICON06)
If Count > 3 Then DrawIcon( 1,41,0,0,ICON11) Break
Count++
EndWhile
DrawNumber(150,20,Count)
Count$ = "A" Count = 0
Count1$ = "C" Count1= 0
Count2$ = "E"
While Count$ = "A"
DrawIcon( 1,41,0,0,ICON07)
DrawIcon(41,41,0,0,ICON08)
DrawIcon(81,41,0,0,ICON09)
While Count1$ = "C"
Count1++
If Count1 > 2 Then Count1$ = "D"
DebugMsgBox("Inside inner loop#1")
While Count2$ = "E"
Count2++
If Count2 > 2 Then Count2$ = "F"
DebugMsgBox("Inside inner loop#2")
EndWhile
EndWhile
If Count > 3 Then Count$ = "B"
Count++
EndWhile
DrawNumber(150,50,Count)
DrawText(10,80,"Outer Structured While Loop complete.")
Goto Wait_for_Input
ForIfWhile:
DrawBackground
X = 1 Y = 1
For A = 0 To 10
C = A
While C < 10
If A < 5
DrawIcon(1,1,0,0,ICON01)
Else
While X < 10
DrawIcon(X,Y,0,0,ICON10)
X +=2 Y += 2
EndWhile
Endif
C++
EndWhile
Next
For A = 0 To 10
C = A
If A < 5
DrawIcon(1,1,0,0,ICON01)
Else
While X < 10
DrawIcon(X,Y,0,0,ICON10)
X +=2 Y += 2
EndWhile
Endif
C++
Next
Goto Wait_for_Input